package com.yyh3;

public class MyDate {
    //属性
    //年
    private int year;
    //月
    private int month;
    //日
    private int day;
    //满参构造
    public MyDate(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    //行为
    //打印日期方法
    public void showDate(){
        System.out.println(year+"年"+month+"月"+day+"日");
    }
    //判断闰年方法
    public boolean isLeapYear(){
        if (year % 100 == 0) {
            // 世纪年：能被400整除是闰年
            return year % 400 == 0;
        } else {
            // 普通年：能被4整除是闰年
            return year % 4 == 0;
        }
    }
}
